import {networkInterfaces} from 'os'
const getIp = ()=>{
    const info = networkInterfaces()
    // console.log(`info start`);
    // console.log(info)
    let ip = '127.0.0.1'
    let temp = false
    const reg = /^\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}$/
    // const { address } = info?.WLAN?.find(e=>/^\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}$/.test(e.address))
    for(let key in info){
        temp = info[key].find(e=>reg.test(e.address))
    }
    ip = temp?.address || ip;  
    return ip
}

export {getIp}